package com.cms.dao.dialect;

import com.cms.constant.CmsConstant;
import com.cms.exception.SystemDBException;


/***
 * 
 * @author hongwu.huang
 *
 */
public class MySQlPagingDialectService implements DataBasePagingDialectService {

	@Override
	public String generatePagingSQL(String rsSql) throws SystemDBException {
		StringBuilder sb = new StringBuilder();
		sb.append(" SELECT * FROM (");
		sb.append(rsSql).append(" )TEMP LIMIT :").append(CmsConstant.PAGE_START_INDEX);
		sb.append(",");
		sb.append(":").append(CmsConstant.PAGE_END_INDEX);
		return sb.toString();
	}

	@Override
	public String generatePagingCountSQL(String rsSql) throws SystemDBException {
		StringBuilder sb = new StringBuilder();
		sb.append(" SELECT COUNT(0) AS COUNT FROM (");
		sb.append(rsSql).append(" )TEMP ");
		return sb.toString();
	}

}
